package tr.helper.controller.home;

import java.awt.PopupMenu;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;
import tr.helper.SingletonFactory;
import tr.helper.UserHolder;

public class HomeMain extends Application {

    private static Stage instance = null;

    public static Stage getInstance() {
        if (null == instance) {
            instance = SingletonFactory.getWeakInstance(Stage.class, null);
        }
        return instance;
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        enableTray(getInstance());
        getInstance().setOnCloseRequest(event -> {
            getInstance().hide();
        });

        getInstance().setTitle("辅助中心 欢迎你:" + UserHolder.getInstance().getUser().getUsername());
        getInstance().setScene(new Scene(FXMLLoader.load(HomeMain.class.getResource("HomeForm.fxml"))));
        getInstance().show();
    }

    //右小角,最小化.
    private void enableTray(final Stage stage) {
        PopupMenu popupMenu = new PopupMenu();
        MenuItem openItem = new MenuItem("显示");
        MenuItem hideItem = new MenuItem("最小化");
        MenuItem quitItem = new MenuItem("退出");
    }

}
